package com.njth.beans;

import java.util.Date;

/*
 * author hanbing
 * 新闻类
 */
public class News extends BaseBean{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4552793297471705898L;

	private String newspic; /* 新闻中的图片 */

	private String title; /* 新闻标题 */

	private String context; /* 新闻内容 */

	private String author; /* 新闻发布者 */

	private Date datetime; /* 新闻提交时间 */

	public News() {

	}

	public News(int id, String title, String context, String newspic,
			String author, Date datetime) {
		super.setId(id);
		this.title = title;
		this.newspic = newspic;
		this.author = author;
		this.datetime = datetime;
		this.context = context;
	}

	/*
	 * 一下是分别各自属性的SET和GET方法
	 */
	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getContext() {
		return context;
	}

	public void setContext(String context) {
		this.context = context;
	}

	public Date getDatetime() {
		return datetime;
	}

	public void setDatetime(Date datetime) {
		this.datetime = datetime;
	}

	public String getNewspic() {
		return newspic;
	}

	public void setNewspic(String newspic) {
		this.newspic = newspic;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	/*
	 * 获取新闻简短内容用于页面展示部分新闻内容
	 */
	public String getSummary(int offset) {
		if(this.context==null){
			return null;
		}
		if (this.context.length() < offset) {
			return context;
		} else {
			return context.substring(0, offset);
		}
	}
}
